import api.utils.APImap;
import api.utils.ToolsAPI;
import bean.ListAllCardBean;
import bean.ListAllCardDictBean;
import bean.OperatorGrantLogPageBean;
import org.testng.annotations.Test;

import java.util.HashMap;
import java.util.Map;

/**
 * 工作台-
 * 编辑内容-
 * 展示内容下拉列表数据
 * 获取授权记录
 */
public class Workbench<T> extends ToolsAPI<T> {

    @Test(description = "获取授权记录", enabled = true, priority = 0)
    public void operatorGrantLog_page() {
        //{"pageIndex":1,"pageSize":20,"param":{"operatorName":"搜索内容"}}
        Map paramMap = new HashMap();
        paramMap.put("operatorName", "搜索内容");
        put("pageIndex", 1);
        put("pageSize", 20);
        put("param", paramMap);
        OperatorGrantLogPageBean bean = runAPI(retrofit.operatorGrantLog_page(toBody(map)), "operatorGrantLog_page");
        assertFalse(bean.getData().getDatas().size() <= 0, "无授权记录为空");
    }

    @Test(description = "获取授权记录-验证返回用户名、创建时间是否为空", priority = 1)
    public void operatorGrantLog_page_Name() {
        OperatorGrantLogPageBean bean = APImap.getApiMap("operatorGrantLog_page");
        bean.getData().getPageSize();
        if (bean.getData().getDatas().size() > 0) {
            for (OperatorGrantLogPageBean.DatasItem item : bean.getData().getDatas()) {
                assertFalse(item.getOperatorName().equals(""), "operatorName不应该返回空字符");
                assertFalse(item.getCreateTime().equals(""), "createTime不应该返回空字符");
            }
        }
    }

    @Test(description = "展示内容下拉列表数据", enabled = true, priority = 2)
    public void listAllCardDict() {
        ListAllCardDictBean bean = runAPI(retrofit.listAllCardDict(), "listAllCardDict");
        assertFalse(bean.getData().size() <= 0, "展示内容下拉列表数据为空");
        for (ListAllCardDictBean.DataBean item : bean.getData()) {
            assertFalse(item.getName().equals(""), "下拉列表数据name字符不能返回空字符串");
        }
    }

    @Test(description = "工作台-视图数据", enabled = true, priority = 3)
    public void listAllCard() {
        ListAllCardBean bean = runAPI(retrofit.listAllCardDict(), "listAllCard");
        for (ListAllCardBean.DataBean item : bean.getData()) {
            assertFalse(item.getName().equals(""), "视图数据name字符不能返回空字符串");
        }
    }
}
